C++ Templates: The Complete Guide by David Vandevoorde & Nicolai M. Josuttis & Douglas Gregor

C++ Templates: The Complete Guide by David Vandevoorde & Nicolai M. Josuttis & Douglas Gregor

Author:David Vandevoorde & Nicolai M. Josuttis & Douglas Gregor [Vandevoorde, David]
Language: eng
Format: azw3, pdf, epub
ISBN: 9780134778747
Publisher: Pearson Education
Published: 2017-09-15T04:00:00+00:00


18.1 Dynamic Polymorphism

Historically, C++ started with supporting polymorphism only through the use of inheritance combined with virtual functions.2 The art of polymorphic design in this context consists of identifying a common set of capabilities among related object types and declaring them as virtual function interfaces in a common base class.

The poster child for this design approach is an application that manages geometric shapes and allows them to be rendered in some way (e.g., on a screen). In such an application, we might identify an abstract base class (ABC) GeoObj, which declares the common operations and properties applicable to geometric objects. Each concrete class for specific geometric objects then derives from GeoObj (see Figure 18.1):



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.